﻿namespace GCC.Container.Comm.Modbus.TCPVersion
{
    /// <summary>
    /// TCP包
    /// </summary>
    public class ModbusTcpPackage
    {
        /// <summary>
        /// 设备地址
        /// </summary>
        public byte DeviceIndex { get; set; }

        /// <summary>
        /// 功能码
        /// </summary>
        public ModbusTcpFeatureEnum Feature { get; set; }

        /// <summary>
        /// 数据区
        /// </summary>
        public byte[]? Data { get; set; }


        /// <summary>
        /// 功能码枚举
        /// </summary>
        public enum ModbusTcpFeatureEnum : byte
        {
            /// <summary>
            /// 读线圈
            /// </summary>
            ReadCoils = 0x01,
            /// <summary>
            /// 读离输入状态
            /// </summary>
            ReadInputState = 0x02,
            /// <summary>
            /// 读保持寄存器
            /// </summary>
            ReadHodingRegister = 0x03,
            /// <summary>
            /// 读输入寄存器
            /// </summary>
            ReadInputRegister = 0x04,
            /// <summary>
            /// 写单个线圈
            /// </summary>
            WriteCoils = 0x05,
            /// <summary>
            /// 写单个保持寄存器
            /// </summary>
            WriteHodingRegister = 0x06,
            /// <summary>
            /// 写多个线圈
            /// </summary>
            WriteMutipleCoils = 0x0F,
            /// <summary>
            /// 写多个保持寄存器
            /// </summary>
            WriteMutipleHodingRegister = 0x10,
        }
    }
}
